//
//  UIApplication+Extension.swift
//  FuXingApp
//
//  Created by hungraim on 2021/8/2.
//
import UIKit

extension UIApplication {
    /// app启动, 相关通知监听
    func applicationLunch() {
        
        addNotificationObserver()
    }
    
    /// 添加监听
    fileprivate func addNotificationObserver() {
        // 弹出登录页
        NotificationCenter.default.addObserver(self, selector: #selector(showQuickLoginController), name: .AppShowLoginController, object: nil)
        // 登录
        NotificationCenter.default.addObserver(self, selector: #selector(userLogIn(_:)), name: NSNotification.Name.AppLogIn, object: nil)
    }


    @objc fileprivate func showQuickLoginController() -> UINavigationController {

        let nav = NavigationController.init(rootViewController: SSPhoneLoginViewController())
        nav.modalPresentationStyle = .fullScreen
        UIViewController.current().tabBarController?.present(nav, animated: true, completion: nil)
//        UIViewController.current().present(nav, animated: true, completion: nil)
        return nav
        
    }

    @objc fileprivate func userLogIn(_ note: Notification) {
        UIViewController.current().dismiss(animated: true)
    }

}
